_building_creation_pos = [2759,12107,0];
_initial_pos_player = [2771,12172,0];

// If (isNil "D_AVAILABLE_BUILDING_LIST") then {
	// D_AVAILABLE_BUILDING_LIST = +BUILDING_POSITION_INDEXER;
// };
// If (isNil "D_CURRENT_BUILDING") then {
	// D_CURRENT_BUILDING = objNull;
// };
// diag_log Format["%1",D_AVAILABLE_BUILDING_LIST];
// If ((IsNull D_CURRENT_BUILDING) AND (count D_AVAILABLE_BUILDING_LIST > 0)) then {
	// D_CURRENT_BUILDING_NAME = D_AVAILABLE_BUILDING_LIST select 0;
	// D_AVAILABLE_BUILDING_LIST set [0,"XdelX"];
	// D_AVAILABLE_BUILDING_LIST = D_AVAILABLE_BUILDING_LIST - ["XdelX"];
	// D_CURRENT_BUILDING = CreateVehicle [D_CURRENT_BUILDING_NAME,_building_creation_pos, [], 0, "NONE"];
	// D_CURRENT_BUILDING setDir random(360);
	// //D_CURRENT_BUILDING setDir 0;
	// D_CURRENT_ARRAY = 0;
	// D_CURRENT_INDEX = 0;
	// sleep 1;
// };
// diag_log Format["%1: %2",D_CURRENT_BUILDING_NAME, D_CURRENT_BUILDING];
// If (isNull D_CURRENT_BUILDING) exitWith {player sideChat "All buildings are tested!"};
// If (isNil "D_CURRENT_ARRAY") then {
	// D_CURRENT_ARRAY = 0;
// };
// If (isNil "D_CURRENT_INDEX") then {
	// D_CURRENT_INDEX = 0;
// };
// _position = BUILDING_POSITION_INDEXER find D_CURRENT_BUILDING_NAME;
// if (_position < 0) exitWith {
	// player sideChat Format["Building not found: ",D_CURRENT_BUILDING_NAME ];
	// player setPos _initial_pos_player;
	// sleep 1;
	// D_CURRENT_BUILDING_NAME = "";
	// deleteVehicle D_CURRENT_BUILDING;
	// sleep 1;
	// D_CURRENT_BUILDING = objNull;
// };

// _building_array = BUILDING_POSITION_INFOS select _position;
// If (count _building_array < 3) exitWith  {
	// player sideChat Format["Building array not full (%1): %2",D_CURRENT_BUILDING_NAME,_building_array ];
	// player setPos _initial_pos_player;
	// sleep 1;
	// D_CURRENT_BUILDING_NAME = "";
	// deleteVehicle D_CURRENT_BUILDING;
	// sleep 1;
	// D_CURRENT_BUILDING = objNull;
	// D_CURRENT_ARRAY = 0;
	// D_CURRENT_INDEX = 0;
// };

// _sub_array = _building_array select D_CURRENT_ARRAY;
// if ((count _sub_array == 0) Or (count _sub_array <= D_CURRENT_INDEX)) exitWith {
	// D_CURRENT_ARRAY = D_CURRENT_ARRAY + 1;
	// D_CURRENT_INDEX = 0;
	// if (D_CURRENT_ARRAY > 2) then {
		// player sideChat Format["Building arrays completed: %1",D_CURRENT_BUILDING_NAME];
		// player setPos _initial_pos_player;
		// sleep 1;
		// D_CURRENT_BUILDING_NAME = "";
		// deleteVehicle D_CURRENT_BUILDING;
		// sleep 1;
		// D_CURRENT_BUILDING = objNull;
		// D_CURRENT_ARRAY = 0;
		// D_CURRENT_INDEX = 0;
	// } else {
		// player sideChat Format["Current building array completed (%1): %2",D_CURRENT_BUILDING_NAME,(D_CURRENT_ARRAY - 1)];
	// };
// };

// _pos_info = _sub_array select D_CURRENT_INDEX;
// _rel_position = _pos_info select 0;
// _angle = _pos_info select 1;
// _angle = _angle + getDir D_CURRENT_BUILDING;
// D_CURRENT_INDEX = D_CURRENT_INDEX + 1;
// _position = D_CURRENT_BUILDING modelToWorld _rel_position;
// player sideChat Format["Building pos %1",getPosAtl D_CURRENT_BUILDING];
// _position = [getPosAsl D_CURRENT_BUILDING, getDir D_CURRENT_BUILDING, _rel_position] call XfBuildingPositionCalculator;
// player sideChat Format["Moved to position %1 calculated from %2 (%3,%4)",_position,_rel_position,D_CURRENT_ARRAY,D_CURRENT_INDEX];
// player setDir _angle;
// player setPosAsl _position;
// //player setPosAsl _position;
// sleep 1;

// Automatic loop through all buildings
_current_building = objNull;
for [{_i = 0},{_i < count BUILDING_POSITION_INDEXER},{_i = _i + 1}] do
{
	if (!isNull _current_building) then {
		player setDir 180;
		player setPos _initial_pos_player;
		deleteVehicle _current_building;
		sleep 2;
	};
	_building_type = BUILDING_POSITION_INDEXER select _i;
	_building_pos_infos = BUILDING_POSITION_INFOS select _i;
	_current_building = CreateVehicle [_building_type,_building_creation_pos, [], 0, "NONE"];
	_current_building setDir random(360);
	sleep 2;
	{
		_building_pos_types = +_x;
		If (count _building_pos_types > 0) then {
			{
				_pos_info = +_x;
				_pos = _pos_info select 0; 
				_angle = _pos_info select 1;
				_angle = _angle + getDir _current_building;
				_position = [getPosAsl _current_building, getDir _current_building, _pos] call XfBuildingPositionCalculator;
				player sideChat Format["Moving To: %1 => %2",_pos_info, _position];
				sleep 1;
				player setDir _angle;
				player setPosAsl _position;
				sleep 3;
			} foreach _building_pos_types;
		};
	} foreach _building_pos_infos;
};